namespace Gamov.Net6.Core.Helper
{
    using System;
    using System.Linq;
    using System.Reflection;
    using Microsoft.Extensions.DependencyInjection;

    public static class ReflectsHelper
    {
        public static MethodInfo OptionsServiceCollectionExtensions_AddOptions(Type genericType)
        {
            var method1 = typeof(OptionsServiceCollectionExtensions).GetMethod("AddOptions", 1, new Type[] { typeof(IServiceCollection) });
            method1 = method1.MakeGenericMethod(genericType);
            return method1;
        }

        public static MethodInfo OptionsBuilderConfigurationExtensions_Bind(Type genericType)
        {
            var method1 = typeof(OptionsBuilderConfigurationExtensions).GetMethods().First(a => a.Name == "Bind" && a.GetParameters().Count() == 2);
            method1 = method1.MakeGenericMethod(genericType);
            return method1;
        }

        public static MethodInfo ServiceCollectionHostedServiceExtensions_AddHostedService(Type genericType)
        {
            var method = typeof(ServiceCollectionHostedServiceExtensions).GetMethod("AddHostedService", new Type[] { typeof(IServiceCollection) });
            method = method.MakeGenericMethod(genericType);
            return method;
        }

    }
}
